package sample;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlValue;

@XmlAccessorType(XmlAccessType.FIELD)
public class Question {
	@XmlAttribute(name="id")
	private String id;
	@XmlAttribute(name="from")
	private String from;
	@XmlAttribute(name="solved")
	private boolean solved;
	@XmlValue
	private String content;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	public boolean isSolved() {
		return solved;
	}
	public void setSolved(boolean solved) {
		this.solved = solved;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@Override
	public String toString() {
		String template="[%s]%s.[%s] from %s";
		String solvedLabel=isSolved()?"SOLVED":"UNSOLVED";
		return String.format(template, solvedLabel,id,content,from);
		//return "Question [id=" + id + ", from=" + from + ", solved=" + solved + ", content=" + content + "]";
	}
	
}
